in the InitPartFromStorage. Whenever the potential for changing user content exists, the part should check to make sure
fPermissions >= kDPSharedWrite
before changing any of the content. Also, as a side effect, if fPermissions < kDPSharedWrite then fDirty should never be able to become kODTrue, and as a result, the Externalize method will never write to the contents property.
PartWrapper
In addition to a Storage Unit, InitPart and InitPartFromStorage methods on ODPart also takes an extra parameter partWrapper. The partWrapper parameter represents a delegator object which OpenDoc uses to insulate the rest of OpenDoc from having to have a direct pointer to your ODPart object. This feature helps implement features such as being able to change the editor of part without closing and reopening the document. Plus, it makes an excellent bottleneck for platform developers. For the most part, all the partWrapper does is delegate methods of the part API to your ODPart object.
The Part Editor must save this parameter in the Part's internal field; you'll see this in the sample code below. Whenever an OpenDoc API requires the Part Editor to pass in an ODPart* representing the Part, instead of passing in somSelf, the Part Editor MUST pass in partWrapper stored in the Part's internal field. An example is when registering the Part for idle time. A Part Editor should NEVER pass somSelf in as a parameter to an OpenDoc API call.
Sample Code for Initialization
// includes the appropriate .xh files from OpenDoc
#include "StorageU.xh"
#include "StdProps.xh"
#include "POUtils.h"
…
// Define the Part Kind.
//
// This should probably be in your part's …def.h file which should be #included